package com.hdsx.jxcsxm.utile.excel;

import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;

public class ExcelUtil {
	
	public static HSSFCellStyle getHSSFCellStyleCenter(HSSFWorkbook wb){
		//-----------------------文字居中
		HSSFCellStyle style = wb.createCellStyle();
		style.setAlignment(XSSFCellStyle.ALIGN_CENTER);//单元格水平居中
		style.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);//单元格垂直居中
		style.setBorderTop(XSSFCellStyle.BORDER_THIN);
	    style.setBorderBottom(XSSFCellStyle.BORDER_THIN);
	    style.setBorderLeft(XSSFCellStyle.BORDER_THIN);
	    style.setBorderRight(XSSFCellStyle.BORDER_THIN);
	    style.setWrapText(true);
	    HSSFFont font = wb.createFont();
	    font.setFontName("宋体");
	    font.setFontHeightInPoints((short) 11);
	    style.setFont(font);//选择需要用到的字体格式
		return style;
		
	}
	
	public static HSSFCellStyle getHSSFCellStyleLeft(HSSFWorkbook wb){
		//-----------------------文字居左
		HSSFCellStyle styleleft = wb.createCellStyle();
	    styleleft.setAlignment(XSSFCellStyle.ALIGN_LEFT);//单元格水平居中
	    styleleft.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);//单元格垂直居中
	    styleleft.setBorderTop(XSSFCellStyle.BORDER_THIN);
	    styleleft.setBorderBottom(XSSFCellStyle.BORDER_THIN);
	    styleleft.setBorderLeft(XSSFCellStyle.BORDER_THIN);
	    styleleft.setBorderRight(XSSFCellStyle.BORDER_THIN);
	    styleleft.setWrapText(true);
	    HSSFFont fontleft = wb.createFont();
	    fontleft.setFontName("宋体");
	    fontleft.setFontHeightInPoints((short) 11);
	    styleleft.setFont(fontleft);//选择需要用到的字体格式
	    return styleleft;
		
	}
	
	public static HSSFCellStyle getHSSFCellStyleWeght(HSSFWorkbook wb){
		//-----------------------文字居左
		HSSFCellStyle stylweght = wb.createCellStyle();
  		stylweght.setAlignment(XSSFCellStyle.ALIGN_CENTER);//单元格水平居中
  		stylweght.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);//单元格垂直居中
  		stylweght.setBorderTop(XSSFCellStyle.BORDER_THIN);
  		stylweght.setBorderBottom(XSSFCellStyle.BORDER_THIN);
  		stylweght.setBorderLeft(XSSFCellStyle.BORDER_THIN);
  		stylweght.setBorderRight(XSSFCellStyle.BORDER_THIN);
  		stylweght.setWrapText(true);
  	    HSSFFont fontweight = wb.createFont();
  	    fontweight.setFontName("宋体");
  	    fontweight.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  	    fontweight.setFontHeightInPoints((short) 11);
  	    stylweght.setFont(fontweight);//选择需要用到的字体格式
  	    return stylweght;
		
	}	

}
